package club.banyuan.reserve.controller.api;

import club.banyuan.reserve.common.CommonResult;
import club.banyuan.reserve.model.User;
import club.banyuan.reserve.service.OrderService;
import club.banyuan.reserve.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author HanChao
 * 描述信息：
 */
@RestController
@RequestMapping("/api/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping(value = "/list")
    public CommonResult list (HttpSession session) {

        User user = (User) session.getAttribute("user");
        if (user == null) {
            return CommonResult.failed("no");
        }

        List<OrderVo> list = orderService.showOrderListByUserId(user.getId());

        return CommonResult.success(list);
    }
}
